using UnityEngine;

public class CarSteerArrow : MonoBehaviour
{
	public static CarSteerArrow instance;

	public GameObject holder;

	private float maxAmgel = 60f;

	private float noSteerTimer = 1f;

	private bool onThresHold;

	private void Awake()
	{
		instance = this;
	}

	private void Update()
	{
		if (PlayerBehavior.MyPlayer != null && PlayerBehavior.MyPlayer.currentCar != null && PlayerBehavior.MyPlayer.currentCar is CarBehavior && PlayerBehavior.MyPlayer.currentCar.Type == CarType.Car)
		{
			SetThresHold();
			if (!onThresHold)
			{
				holder.SetActive(true);
				float num = (PlayerBehavior.MyPlayer.currentCar as CarBehavior).RCCcar.steerInput * maxAmgel;
				if (num > maxAmgel)
				{
					num = maxAmgel;
				}
				else if (num < 0f - maxAmgel)
				{
					num = 0f - maxAmgel;
				}
				base.transform.rotation = Quaternion.Lerp(base.transform.rotation, Quaternion.Euler(0f, num, 0f), Time.deltaTime * 10f);
			}
			else
			{
				holder.SetActive(false);
			}
		}
		else
		{
			holder.SetActive(false);
		}
	}

	private void SetThresHold()
	{
		if (!TPSCamera.instance.isRotating && Mathf.Abs((PlayerBehavior.MyPlayer.currentCar as CarBehavior).RCCcar.steerInput) <= 0.05f)
		{
			noSteerTimer += Time.deltaTime;
		}
		else
		{
			noSteerTimer = 0f;
		}
		if (noSteerTimer >= 0.75f)
		{
			onThresHold = true;
		}
		else
		{
			onThresHold = false;
		}
	}
}
